home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7666 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.9 KB  |  71 lines

  1. Path: news.sprintlink.net!rockyd!cmcl2!schonberg!dewar
  2. From: dewar@cs.nyu.edu (Robert Dewar)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: on OO differnces between Ada95 and C++
  5. Date: 24 Feb 1996 10:56:24 -0500
  6. Organization: Courant Institute of Mathematical Sciences
  7. Message-ID: <dewar.825176840@schonberg>
  8. References: <4gbq7q$g08@qualcomm.com> <3129F185.41C6@Rational.COM> <dewar.824905880@schonberg> <312C5160.41C6@Rational.COM>
  9. NNTP-Posting-Host: schonberg.cs.nyu.edu
  10. X-Newsreader: NN version 6.5.0 (NOV)
  11.  
  12. Jerome said, answering me:
  13.  
  14. > for Ada files, and GNAT does not require specs to be explicitly
  15. > compiled
  16.  
  17. Even GNAT will perform a semantic analysis of Ada specs. Try to run a
  18. C++ compiler against a .h file!
  19.  
  20. Absolutely true. I was using compiled here in the sense of creating an
  21. object file.
  22.  
  23. GNAT does not create object files for:
  24.  
  25.   subunits
  26.   generic units
  27.   package specs that require a body
  28.  
  29. However, it is perfectly fine, and very useful, to be able to compile
  30. all these kinds of units using the -gnatc swich that asks GNAT to
  31. fully check the syntax and semantics. It is indeed an important advantage
  32. of Ada that such checking is possible (you said "try to run a C++ compiler
  33. against a .h file", and of course a similar suggestion is "try to run a
  34. C++ compiler against a template". In Ada, the generic contract model means
  35. that a generic body that compiles clean will always instantiate clean, but
  36. that of course is not the case for C++ templates. It is true that you get
  37. some extra flexibility in return for this freedom in C++, but for the
  38. construction of large systems, the contract model is an important guarantee
  39. (so important that it is the one place in Ada 95 where an incompatible
  40. change was made to Ada 83 to fix up the one serious hole in the model,
  41. namely the business of passing unconstrained types).
  42.  
  43. In a small program with GNAT, you don't need to bother to compile 
  44. these non-object-producing units at all, since you will find the
  45. errors immediately from the clients, and can then fix up whatever
  46. needs fixing.
  47.  
  48. But in a large program, the ability to verify specs, subunits, and generics
  49. independently is critical (and required by the RM), so there the use of
  50. the -gnatc switch is very useful.
  51.  
  52. Note: if you attempt to compile any of the above units to produce object
  53. files (by omitting the -gnatc), then an error is signalled:
  54.  
  55.   No code generated for file xxx (package spec)
  56.  
  57. or somesuch. The error message is needed (and the compiler will indicate
  58. error status) because the expected object file is not produced. Actually
  59. I think I wll change the message to
  60.  
  61.   No object file created for file xxx (...)
  62.  
  63. since that is clearer. 
  64.  
  65. If you find this confusing, just follow the proper procedure, which is
  66. to use -gnatc when compiling a subunit, generic unit, or package spec.
  67. Note also that -gnatc is useful when comilling a parent unit with subunits,
  68. it checks the syntax and semantics JUST of the parent unit, without checking
  69. the subunits.
  70.  
  71.